package com.example.ssm.controller;

import com.alibaba.fastjson.JSONObject;
import com.example.ssm.entity.Student;
import com.example.ssm.service.StudentService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


/**
 * greeting
 * @author Administrator
 */
@RestController
@RequestMapping("/go")
public class Greeting {

    @Resource(name = "ser1")
    private StudentService studentService;

    // http://localhost:8080/mapp/go/in
    @RequestMapping("/in")
    public String greetings(){
        Student students =studentService.getById("12345");
        Student param = new Student();
        param.setId("0002");
        param.setCode("code002");
        studentService.testTransaction(param);
        return "greeting seeker!" + students.toString();
    }

    @GetMapping("/testGet")
    public String testGet(@RequestParam("id") String id){
        Student students =studentService.getById(id);
        /*Student param = new Student();
        param.setId("0002");
        param.setCode("code002");
        studentService.testTransaction(param);*/
        return "greeting seeker!" + students.toString();
    }

    @PostMapping("/testPost")
    public String testPost(@RequestBody JSONObject jo){
        String id = jo.getString("id");
        Student students =studentService.getById(id);
        return "testPost seeker!" + students.toString();
    }
}
